package com.demo.datastructure.recursion;

/**
 * @author ljr
 * @version 1.0
 * @description: 递归实现黄金柱问题
 * @date 2021/10/13 10:45
 */
public class MyRecusion2 {

    public static void main(String[] args) {
        moveTower(4, "A", "B", "C");
    }

    private static void moveTower(int n, String from, String with, String to) {
        if(n == 1){
            moveDisk(n, from, to);
            return;
        }
        moveTower(n-1, from, to, with);
        moveDisk(n, from, to);
        moveTower(n-1, with, from, to);
    }

    private static void moveDisk(int n, String from, String to) {
        System.out.printf("Moving disk[%s] from {%s} to {%s}\n", n, from, to);
    }


}
